#!/usr/bin/python
#example code, lecture 7

##Ivys=[ 'MIT','Cal','Princeton' ]
#print Ivys
#Ivys[ 1 ]=-15
##Ivys[ 2 ]=-15
##couldn't do it
#print Ivys

##List
#L1 = [ 1,2,3 ]
#L2 = L1
#print L2
#L1[ 0 ] = 4
##print L1
#print L2
#L1 = [   ]
#print L1
#print L2

#Dictionary
def showDicts():
    EtoF = { 'one':'un', 'soccer':'football', 'never':'jaesis' }
    print EtoF[ 'soccer' ]
    raw_input()
    #print EtoF[ 0 ]
    #don't have a index
    print EtoF
    raw_input()
    NtoS = { 1:'one', 2:'two', 'one':1, 'two':2 }
    print NtoS
    print NtoS.keys()
    raw_input()
    print NtoS.keys
    raw_input()
    del NtoS[ 'one' ]
    print NtoS
    raw_input()

#run function show dictionary
#showDicts()


##import math
##
###Get base
##inputOK = False
##while not inputOK:
##    base = input( 'Enter base:' )
##    if type( base ) == type( 1.0 ):inputOK =True
##    else: print ( 'Error. Base must be a floating point number.' )
##
###Get height
##inputOK = False
##while not inputOK:
##    height = input( 'Enter height:' )
##    if type( height ) == type( 1.0 ):inputOK =True
##    else: print ( 'Error. height must be a floating point number.' )
##
##hyp = math.sqrt( base**2+height**2 )
##print 'Base:' + str( base ) + ', height:' + str( height) + ', hyp:' + str( hyp )

##function method

import math

def getFloat( requestMsg, errorMsg ):
    inputOK = False
    while not inputOK:
        val = input( requestMsg )
        if type( val ) == type( 1.0 ):inputOK = True
        else: print ( errorMsg )
    return val

base = getFloat('Enter base:','Error,base must be a floating point number')
height = getFloat('Enter height:','Error,height must be a floating point number')

hyp = math.sqrt( base**2+height**2 )
print 'Getfloat method result\nBase:' + str( base ) + ', height:' + str( height) + ', hyp:' + str( hyp )


